﻿
namespace Server.Framework.Message
{
    /// <summary>
    /// Author: Leil
    /// Description: 发送消息基础类
    /// CreateTime: 2020/5/12 0:00:23
    /// </summary>
    public abstract class ResponseBaseMessage
    {
        public int MsgId { get; }

        public float Version { get; }

        public ResponseBaseMessage(int msgId)
        {
            MsgId = msgId;
            Version = 1.0f;
        }

        /// <summary>
        /// 消息序列化
        /// </summary>
        /// <returns>序列化后buffer</returns>
        public byte[] Encode()
        {
            byte[] body = Serialize();
            byte[] buffer = MessageDecoder.Encode(Version, MsgId, body);
            return buffer;
        }

        public abstract byte[] Serialize();
    }
}
